using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerBlackHoleState : PlayerState
{
    private float flyTime=0.4f;
    private bool skillUsed;
    private float defaultGravity;
    public PlayerBlackHoleState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName)
    {
    }

    public override void AnimationFinishTrigger()
    {
        base.AnimationFinishTrigger();
    }

    public override void Enter()
    {
        base.Enter();
        defaultGravity = player.rb.gravityScale;
        skillUsed = false;
        stateTimer = flyTime;
        player.rb.gravityScale = 0;
        
    }

    public override void Exit()
    {
        base.Exit();
        player.rb.gravityScale = defaultGravity;
        player.fx.MakeClear(false);
    }

    public override void update()
    {
        base.update();
        if (stateTimer > 0)
        {
            player.rb.velocity = new Vector2(0, 15);

        }
        else
        {
            player.rb.velocity = new Vector2(0, -.1f);
            if (!skillUsed)
            {
                if(player.skill.blackHole.CanUseSkill())
                    skillUsed=true;
           
            }
        }
        if (player.skill.blackHole.BlackHoleFinished())
        {
            stateMachine.ChangeState(player.airState);
        }
    }
}
    

